{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "eaa8e53d",
   "metadata": {},
   "source": [
    "---\n",
    "* 2022/9/5/week03\n",
    "* Python学习记录\n",
    "* Python学习心得\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c8dd4bb4",
   "metadata": {},
   "source": [
    "# 本周学习\n",
    "\n",
    "> 1.模块\n",
    "\n",
    "> 2.变量\n",
    "\n",
    "> 3.循环遍历"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "75887bbe",
   "metadata": {},
   "source": [
    "# 1.模块\n",
    "## 1.1模块(标准库)\n",
    "> Python创始人团队为后面使用这门编程语言的人们提供的解决日常生活可能使用到的功能,而制作的可以方便使用的模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "cd33e753",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7358eaae",
   "metadata": {},
   "source": [
    "* 纪元（1970.1.1）\n",
    "* 时间戳"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "37b89c84",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1664075076.6642196"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "5b10df54",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=25, tm_hour=11, tm_min=5, tm_sec=37, tm_wday=6, tm_yday=268, tm_isdst=0)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "2c83e049",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=25, tm_hour=3, tm_min=5, tm_sec=49, tm_wday=6, tm_yday=268, tm_isdst=0)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.gmtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "3038784f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Sun Sep 25 11:06:10 2022'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.asctime(time.localtime())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "47a1ee7e",
   "metadata": {},
   "source": [
    "## 1.2模块（开源模块）\n",
    "> 1.因为代码开源\n",
    "\n",
    "> 2.集合全领域(全人类)的需求\n",
    "\n",
    "> 3.按照国际标准开放的模块库\n",
    "\n",
    "## 1.3模块(自定义模块)\n",
    "> 1.不愿意开源的有一定知识产权的(开放API租用形式开放)\n",
    "\n",
    "> 2.自己用的,写的也不怎么好,开源出去丢人的"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f8910275",
   "metadata": {},
   "source": [
    "# 2.变量\n",
    "* 1.声明变量（命名）规则\n",
    "\n",
    "> 1.变量名只能是字母、数字或下划线的任意组合\n",
    "\n",
    "> 2.变量名的第一个字符不能是数字\n",
    "\n",
    "> 3.以下关键字不能声明为变量名 ['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda','not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield'] 在jupyter 中显示绿色的不能命名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "41dbf963",
   "metadata": {},
   "outputs": [],
   "source": [
    "网二_01_name = \"xiao hong\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "5e43d5cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'xiao hong'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_01_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "7463133a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2133632252912"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "id(网二_01_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "92f12b1d",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (1227287278.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [12]\u001b[1;36m\u001b[0m\n\u001b[1;33m    1网二 = \"xiaoming\"\u001b[0m\n\u001b[1;37m     ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "1网二 = \"xiaoming\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "f73b7e7f",
   "metadata": {},
   "outputs": [],
   "source": [
    "网二_01_age = 19"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "1c045fe5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "19"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_01_age"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "27e14359",
   "metadata": {},
   "source": [
    "# 案例（关于变量）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "89bd6150",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "210000001 210000001\n",
      "210000006 210000001\n"
     ]
    }
   ],
   "source": [
    "网二_01_ID = \"210000001\"\n",
    "\n",
    "网二_02_ID = 网二_01_ID\n",
    "\n",
    "print(网二_01_ID,网二_02_ID)\n",
    "\n",
    "网二_01_ID = \"210000006\"\n",
    "\n",
    "print(网二_01_ID,网二_02_ID)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c1968cd5",
   "metadata": {},
   "source": [
    "# 课后作业及思考"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "0391b94f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "this minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "\n",
    "odds = {1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59}\n",
    "\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"this minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an add minute.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "485ffae1",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
